Skip to main content
This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal

Notes/Domino 6 and 7 Forum

Notes/Domino 6 and 7 Forum


  

PreviousPrevious NextNext


~Vanessa Dwofreeskioden 5.Jan.04 11:49 AM a Web browser
Domino Designer All Releases All Platforms


I am calling a Java agent from a lotus notes agent to send email in HTML format. We used this code on v5.10 and it worked fine after updating the server to 6.0.3 it is not working correctly. Anyone have an ideas, help is greatly appreciated, more information below. It keeps giving an error of:

Agent error: java.net.SocketException: Connection reset by peer: socket closed

==============================================================================================

Below is the lotus notes code to call the java agent:

Set JavaAgent = db.GetAgent( "JavaEmail")

If Not(JavaAgent Is Nothing) Then
status = JavaAgent.RunOnServer (MailDoc.noteid)
End If

Set JavaAgent = Nothing

==============================================================================================

Below is the JavaAgent

import lotus.domino.*;
import java.sql.*;
import java.io.*;
import java.net.*;
import java.util.Vector;

public class JavaAgent extends AgentBase {

public void NotesMain() {

try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
Agent agent = agentContext.getCurrentAgent();
Database db = agentContext.getCurrentDatabase();
String tmp_id = agent.getParameterDocID();
Document doc = db.getDocumentByID(agent.getParameterDocID());

// Vars for the socketed conenction to the SMTP server
Socket sock;
DataOutputStream dos;
byte[] b = null;

// Connect to the SMTP server

sock = new Socket( "127.0.0.1", 25 );

BufferedReader br = new BufferedReader(new InputStreamReader(sock.getInputStream()));
dos = new DataOutputStream( sock.getOutputStream() );

// Say hello and reset. Reset not needed if everything OK but it does not hurt.
//Also if server doesn't respond that it will error out, not sending email.
br.readLine();
dos.writeBytes("HELO SERVER/COMPANY\n" );

// From needs to be an Valid SMTP address
dos.writeBytes("MAIL FROM: " + doc.getItemValueString("principal") + " \n");
br.readLine();

// Recipients. One line for each recipient.
br.readLine();

// Need to start data for text and header of the email.
dos.writeBytes("DATA\n");
br.readLine();

//This is the information that will show in the header section of the email. ( To, From and Subject )
dos.writeBytes("To: " + doc.getItemValueString("UserName") + "<" + doc.getItemValueString("sendTo") + "> \n");
dos.writeBytes("From: " + doc.getItemValueString("SentFrom") + "<" + doc.getItemValueString("principal") + "\n"); //" < " + doc.getItemValueString("from") +">\n");
dos.writeBytes("Subject: " + doc.getItemValueString("Subject") +" \n");

// Set the type to HTML
dos.writeBytes("Mime-Version: 1.0\n");
dos.writeBytes("Content-Type: text/html; charset=\"us-ascii\"\n\n");

// Add the Body and end it with full stop on its own line. Note: >1000 chars per line may cause problems.
dos.writeBytes(doc.getItemValueString("body") +" \n");
dos.writeBytes(".\n");

// We are done, quit
dos.writeBytes("QUIT\n");
br.readLine();

// Close the connection
dos.flush();
sock.close();

} catch(Exception e) {
e.printStackTrace();
}
}
}








  Document options
Print this pagePrint this page

 Search this forum

  Forum views and search
Date (threaded)
Date (flat)
With excerpt
Category
Platform
Release
Advanced search

 RSS feedsRSS
All forum posts RSS
All main topics RSS